﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DatabaseService.DatabaseDAO
{
    /// <summary>
    /// Dao层参数实体类
    /// </summary>
    public class DaoParametersEntity
    {
        /// <summary>
        /// mapper对应的id名
        /// </summary>
        private string _method = string.Empty;
        /// <summary>
        /// 参数化SQL所需要的参数列表
        /// </summary>
        private IDictionary<string, object> _parameters = null;

        //public string Method { set => _method = value; }
        //public IDictionary<string, object> Parameters { set => _parameters = value; }

        /// <summary>
        /// 获取mapper对应的id名
        /// </summary>
        /// <returns></returns>
        public string GetMethodName()
        {
            return this._method ?? "";
        }

        /// <summary>
        /// 设定方法名
        /// </summary>
        /// <param name="methodName"></param>
        private void SetMethodName(string methodName)
        {
            if (!string.IsNullOrWhiteSpace(methodName))
                this._method = methodName.Trim();
        }

        /// <summary>
        /// 获取参数化SQL所需要的参数列表
        /// </summary>
        /// <returns></returns>
        public IDictionary<string, object> GetParameters()
        {
            return this._parameters;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="methodId">mapper对应的id名</param>
        public DaoParametersEntity(string methodId)
        {
            this.SetMethodName(methodId);
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="methodId">mapper对应的id名</param>
        /// <param name="parameters">参数化SQL所需要的参数列表</param>
        public DaoParametersEntity(string methodId, IDictionary<string, object> parameters) : this(methodId)
        {
            this._parameters = parameters;
        }
    }
}
